<?php
/**
 * Single Product tabs
 *
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     2.0.0
 */

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

/**
 * Filter tabs and allow third parties to add their own
 *
 * Each tab is an array containing title, callback and priority.
 * @see woocommerce_default_product_tabs()
 */
$tabs = apply_filters( 'woocommerce_product_tabs', array() );

if ( ! empty( $tabs ) ) : ?>

	<div class="woocommerce-tabs">
		<ul class="tabs">
			<?php foreach ( $tabs as $key => $tab ) : ?>

				<li class="<?php echo $key ?>_tab">
					<a href="#tab-<?php echo $key ?>"><?php echo apply_filters( 'woocommerce_product_' . $key . '_tab_title', $tab['title'], $key ) ?></a>
                </li>

			<?php endforeach; ?>
            
            <!-- CUSTOM PRODUCT TAB BUTTONS -->
            <li><a href="#tab-resources">Resources</a></li>
            <li><a href="#tab-videos">Videos</a></li>
            <li><a href="#tab-contact">Contact Us</a></li>
            <li><a href="#tab-faqs">FAQs</a></li>
            <?php if(get_field('iscompareproduct') == 'Yes') { ?>
                <li><a href="#tab-compare">Compare</a></li>
            <?php } ?>
            
		</ul>
		<?php foreach ( $tabs as $key => $tab ) : ?>

			<div class="panel entry-content" id="tab-<?php echo $key ?>">
				<?php call_user_func( $tab['callback'], $key, $tab ) ?>
			</div>

		<?php endforeach; ?>
        
        <!-- CUSTOM PRODUCT TAB CONTENT -->
        <div class="panel entry-content" id="tab-resources">
        	<?php include '/home/silicons/public_html/wp-content/themes/woostore/tab-product-resources.php'; ?>
        </div>
        <div class="panel entry-content" id="tab-videos">
        	<?php include '/home/silicons/public_html/wp-content/themes/woostore/tab-product-videos.php'; ?>
        </div>
        <div class="panel entry-content" id="tab-contact">
        	<?php include '/home/silicons/public_html/wp-content/themes/woostore/tab-product-contact.php'; ?>
        </div>
        <div class="panel entry-content" id="tab-faqs">
        	<?php include '/home/silicons/public_html/wp-content/themes/woostore/tab-product-faqs.php'; ?>
        </div>
        
        <div class="panel entry-content" id="tab-compare">
            <h2>Compare The <?php the_title(); ?></h2>
            <ul>
            <?php // List Compare Product Pages Using This Product Via ID
                $comparepages = new wp_query('post_type=page&meta_key=sscompareproduct&meta_value='.get_the_ID().'');
                    while($comparepages->have_posts()) : $comparepages->the_post();
            ?>
                <li><a href="<?php the_permalink(); ?>">Compare To: <?php the_title(); ?></a></li>
            <?php endwhile; ?>
            <?php wp_reset_query(); ?>
            </ul>
        </div>
        
	</div>

<?php endif; ?>